home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / programming / source / tracker-4.13.lha / tracker / setup_audio.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-02-15  |  2.1 KB  |  111 lines

  1. /* setup_audio.c 
  2.     vi:ts=3 sw=3:
  3.  */
  4. /* higher level interface to the raw metal */
  5.  
  6. /* $Id: setup_audio.c,v 4.7 1995/02/08 13:14:56 espie Exp $
  7.  * $Log: setup_audio.c,v $
  8.  * Revision 4.7  1995/02/08  13:14:56  espie
  9.  * *** empty log message ***
  10.  *
  11.  * Revision 4.7  1995/02/08  13:14:56  espie
  12.  * *** empty log message ***
  13.  *
  14.  * Revision 4.6  1995/02/01  20:41:45  espie
  15.  * Added color.
  16.  *
  17.  * Revision 4.6  1995/02/01  20:41:45  espie
  18.  * Added color.
  19.  *
  20.  * Revision 4.5  1995/02/01  16:39:04  espie
  21.  * *** empty log message ***
  22.  *
  23.  * Revision 4.5  1995/02/01  16:39:04  espie
  24.  * *** empty log message ***
  25.  *
  26.  * Revision 4.0  1994/01/11  17:55:28  espie
  27.  * Use autoinit.
  28.  * Suppressed multiple at_end.
  29.  * Use new pref scheme.
  30.  * Modified in a more consistent way.
  31.  * Added check before closing for the sgi.
  32.  * Added finetune.
  33.  */
  34.  
  35.  
  36.  
  37. #include "defs.h"
  38. #include "extern.h"
  39. #include "tags.h"
  40. #include "prefs.h"
  41.  
  42. ID("$Id: setup_audio.c,v 4.7 1995/02/08 13:14:56 espie Exp $")
  43.  
  44. LOCAL void init_audio P((void));
  45.  
  46. LOCAL void (*INIT)P((void)) = init_audio;
  47.  
  48. LOCAL int opened = FALSE;
  49. LOCAL int ask_freq, real_freq, oversample;
  50. LOCAL int stereo;
  51.  
  52.  
  53. LOCAL void init_audio()
  54.    {
  55.    at_end(do_close_audio);
  56.    }
  57.  
  58. /* setup_audio(frequency, stereo, oversample):
  59.  * try to avoid calling open_audio and other things
  60.  * all the time
  61.  */
  62. void setup_audio(f, s, o)
  63. int f;
  64. int s;
  65. int o;
  66.    {
  67.    INIT_ONCE;
  68.  
  69.    if (!opened)
  70.       {
  71.       ask_freq = f;
  72.       stereo = s;
  73.       oversample = o;
  74.       real_freq = open_audio(f, s);
  75.       init_player(o, real_freq);
  76.       opened = TRUE;
  77.       }
  78.    else
  79.       {
  80.       int new_freq;
  81.  
  82.       if (s != stereo || f != ask_freq)
  83.          {
  84.          ask_freq = f;
  85.          stereo = s;
  86.          close_audio();
  87.          new_freq = open_audio(f, s);
  88.          }
  89.       else
  90.          new_freq = real_freq;
  91.  
  92.       if (new_freq != real_freq || oversample != o)
  93.          {
  94.          real_freq = new_freq;
  95.          oversample = o;
  96.          init_player(o, real_freq);
  97.          }
  98.       }
  99.    set_synchro(get_pref_scalar(PREF_SYNC));
  100.    }
  101.  
  102. void do_close_audio()
  103.    {
  104.    if (opened)
  105.       {
  106.       close_audio();
  107.       }
  108.    opened = FALSE;
  109.    }
  110.  
  111.